﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MVVMDemo.Model
{
    public class Database
    {
        private readonly List<Person> persons;

        public Database()
        {
            this.persons = new List<Person>();

            this.persons.Add(new Person
            {
                FirstName = "Nguyen",
                LastName = "A",
                Age = 23,
                Gender = Gender.Male

            });

             this.persons.Add(new Person
             {
                 FirstName = "Nguyen",
                 LastName = "B",
                 Age = 25,
                 Gender = Gender.Male
             });
        }
        public List<Person> Persons
        {
            get { return this.persons; }
        }

        //Cho phép AddPerson vào Database
        public Person AddPerson(string firstname, string lastname, int age, Gender gender)
        {
            Person newPerson = new Person
            {
                FirstName = firstname,
                LastName = lastname,
                Age = age,
                Gender = gender
            };
            this.persons.Add(newPerson);
            return newPerson;
        }

        // Cho phép remove Person
        public void RemovePerson(Person person)
        {
            this.persons.Remove(person);
        }


    }
}
